home *** CD-ROM | disk | FTP | other *** search
- Path: mayne.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Hashing to a file...
- Date: 1 Apr 1996 19:26:01 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4jq6o9INNaok@mayne.ugrad.cs.ubc.ca>
- References: <Pine.SOL.3.90.960401132142.3433A-100000@kclosure>
- NNTP-Posting-Host: mayne.ugrad.cs.ubc.ca
-
- In article <Pine.SOL.3.90.960401132142.3433A-100000@kclosure>,
- Khan Riaz Ahmad <a228khao@cdf.toronto.edu> wrote:
- >
- > I have been looking for c code for hashing to a file... All the
- >code that I have found so far only show hashing to an array in memory...
- >Anyone know of any good sources for file based hashing???? The main
- >problem I seem to be having is how do we implement the hashing table on
- >the disk...
- >
- >
- >Any help would be greatly appreciated...
- >
- >Riaz.
-
-
- #define hash(STR) (crypt(C[1],C)[0] + crypt(C[2],C)[1] << 8)
-
-
- #include <unistd.h>
- #include <stdio.h>
-
- void main(void)
-
- {
- int x = hash("joe");
- char buffer[5];
-
- FILE *f = fopen("myfile","r");
-
- while(1) {
- if (!fgets(buffer,5,f))
- break;
-
- if (!stcmp(atoi(buffer),x)) {
- puts("found it!");
- break;
- }
- }
- }
- --
-
-